﻿using System;
using Myotragus.Data.Emit;
using Myotragus.Data.Hbm;
using Myotragus.Store.Model.Tests.Domain;
using NUnit.Framework;

namespace Myotragus.Store.Model.Tests
{
  [TestFixture(typeof(ILoadEntityGenerator), typeof(ILoadEntityHbmGenerator))]
  [TestFixture(typeof(ISaveEntityGenerator), typeof(ISaveEntityHbmGenerator))]
  [TestFixture(typeof(IDefaultsSaveEntityGenerator), typeof(IDefaultsSaveEntityHbmGenerator))]
  [TestFixture(typeof(IDefaultsLoadEntityGenerator), typeof(IDefaultsLoadEntityHbmGenerator))]
  public class HbmGeneratorsFixture<TTypeGenerator, THbmGenerator> 
    where TTypeGenerator : ITypeGenerator 
    where THbmGenerator : IHbmGenerator
  {
    [SetUp]
    public void SetUp()
    {
      FixtureHelper.InitializeServices();
    }

    [Test]
    public void GenerationTest()
    {
      var tGen = FixtureHelper.Container.Resolve<TTypeGenerator>();
      var hGen = FixtureHelper.Container.Resolve<THbmGenerator>();

      var type = tGen.GetImplementation(typeof(ILocalizableObject));
      var hbm = hGen.GenerateMapping(type, typeof(ILocalizableObject));

      Console.WriteLine(hbm);
    }
  }
}
